var setting = {
	_pref: null,
	_service: null,
	_user: null,
	_pass: null,
	txtService: null,
	txtUser: null,
	txtPass: null,

	init: function(){
		window.sizeToContent();
		this._pref = new Preferences(PREF_PREFIX);
		this._service = this._pref.getPref("service", DEFAULT_SERVICE);
		this._user = this._pref.getPref("username", DEFAULT_HT_USER);
		this._pass = this._pref.getPref("password", DEFAULT_HT_PASS);

		this.davServer = this._pref.getPref("webdav", DEFAULT_WEBDAV);
	    this.davUser = this._pref.getPref("webdav_user", DEFAULT_WEBDAV_USER);
	    this.davPass = this._pref.getPref("webdav_pass", DEFAULT_WEBDAV_PASS);

		this.txtService = document.getElementById('txtService');
		this.txtUser = document.getElementById('txtUser');
		this.txtPass = document.getElementById('txtPass');

		this.txtDavServer = document.getElementById('txtDavServer');
		this.txtDavUser = document.getElementById('txtDavUser');
		this.txtDavPass = document.getElementById('txtDavPass');

		this.txtService.value = this._service;
		this.txtUser.value = this._user;
		this.txtPass.value = this._pass;

	  this.txtDavServer.value = this.davServer;
	  this.txtDavUser.value = this.davUser;
	  this.txtDavPass.value = this.davPass;
	},

	destory: function(){

	},

	setOptions: function(){
		this._service = this.txtService.value;
		this._user = this.txtUser.value;
		this._pass = this.txtPass.value;

		this.davServer = this.txtDavServer.value;
		this.davUser = this.txtDavUser.value;
		this.davPass = this.txtDavPass.value;
		var stringBundle = document.getElementById("sbLasuli");

		if(this._service == null || this._service.trim() == ""){
			alert(stringBundle.getString("hypertopicOptions.error.serviceisnull"));
			return false;
		}

		var regexp = /http:\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
		if(!regexp.test(this._service)){
			alert(stringBundle.getString("hypertopicOptions.error.serviceisnotanurl"));
			return false;
		}

		if(this.davServer != null && !regexp.test(this.davServer)){
		  alert(stringBundle.getString("hypertopicOptions.error.wdisnotanurl"));
		  return false;
		}

		if(this._service.substr(-1,1) != "/")
			this._service += "/";
    if(this.davServer.substr(-1,1) != "/")
			this.davServer += "/";

		this._pref.setPref("service", this._service);
		this._pref.setPref("username", this._user);
		this._pref.setPref("password", this._pass);

		this._pref.setPref("webdav", this.davServer);
		this._pref.setPref("webdav_user", this.davUser);
		this._pref.setPref("webdav_pass", this.davPass);

		this._pref.savePrefFile();
	}

};